//! `渐进式延迟法定退休年龄政策`
//! 
//! `Policy` 政策条目表
//! 
//! `PersonInfo` 相关人员信息表
//! 
//! `PERSON_TYPE` 单位人员类型表 支持任意人员类别
//! 
//! 层级关系: `PERSON_TYPE` 1 -> [n (单位人员) 1 -> 1] n `PersonInfo` 1 -> [m (适用政策) 1 -> 1] m `Policy`
//! 
//! 经调研 `2025年1月1日` 起施行的政策为我国首次延迟法定退休年龄，结合该次政策实施周期，此类政策不会频繁颁布故无需分离配置文件

use std::collections::HashMap;
use once_cell::sync::Lazy;

pub static PERSON_TYPE: Lazy<HashMap<&'static str, PersonInfo>> = Lazy::new(|| {
    let mut map = HashMap::with_capacity(3);
    // 人员类型及相关政策信息模板
    // map.insert("aaa", PersonInfo(xx, vec![         // aaa: 人员类型; xx: 原法定退休年龄
    //     Policy("yyyy-mm-dd", "aaa"    , x, y, zz), // 政策1 aaa: 人员类型; x: 周期月数 y: 延迟月数 zz: 目标退休年龄
    //     Policy("yyyy-mm-dd", "aaa"    , x, x, zz), // 政策2 aaa: 人员类型; x: 周期月数 y: 延迟月数 zz: 目标退休年龄
    //     ......
    //     Policy("yyyy-mm-dd", "aaa"    , x, x, zz), // 政策n aaa: 人员类型; x: 周期月数 y: 延迟月数 zz: 目标退休年龄
    // ]));
    map.insert("男职工", PersonInfo(60, vec![
        Policy("2025-1-1", "男职工", 4, 1, 63),
    ]));
    map.insert("原法定退休年龄55周岁女职工", PersonInfo(55, vec![
        Policy("2025-1-1", "原法定退休年龄55周岁女职工", 4, 1, 58),
    ]));
    map.insert("原法定退休年龄50周岁女职工", PersonInfo(50, vec![
        Policy("2025-1-1", "原法定退休年龄50周岁女职工", 2, 1, 55),
    ]));
    map
});

/// ```
/// struct Policy { // `渐进式延迟法定退休年龄政策`
///     policy_impl_date: &'static str, // "%Y-%m-%d"
///     object: &'static str,
///     cycle_time: u16, // 单位`月`
///     delay_amount: u16, // 单位`月`
///     target_age: u16
/// }
/// struct PersonInfo {
///     original_statutory_retirement_age: u8,
///     applicable_policies: Vec<Policy>,
/// }
/// ```
pub struct PersonInfo(u16, Vec<Policy>);

impl PersonInfo {
    #[inline(always)]
    pub fn origin_retirement_age(&self) -> u16 {
        self.0
    }
    #[inline(always)]
    pub fn polices(&self) -> &Vec<Policy> {
        &self.1
    }
}

/// 只适用于 `渐进式延迟法定退休年龄政策`
/// ```
/// struct Policy {
///     policy_impl_date: &'static str, // "%Y-%m-%d"
///     object: &'static str,
///     cycle_time: u16, // 单位`月`
///     delay_amount: u16, // 单位`月`
///     target_age: u16
/// }
/// ```
pub struct Policy(&'static str, &'static str, u16, u16, u16);

impl Policy {
    #[inline(always)]
    pub fn policy_impl_date(&self) -> &'static str {
        self.0
    }
    #[inline(always)]
    pub fn object(&self) -> &'static str {
        self.1
    }
    #[inline(always)]
    pub fn cycle_time(&self) -> u16 {
        self.2
    }
    #[inline(always)]
    pub fn delay_amount(&self) -> u16 {
        self.3
    }
    #[inline(always)]
    pub fn target_age(&self) -> u16 {
        self.4
    }
}
